package com.helloworld.upload.domain;

import java.util.ArrayList;
import java.util.List;

public class CellInfo {

	public static class Error {
		private String code;
		private String message;
		
		public Error(String code, String message) {
			this.code = code;
			this.message = message;
		}
		
		public String getCode() { return this.code; }
		public String getMessage() { return this.message; }
		
		@Override
		public String toString() {
			return "code:" + code + ", message:" + message;
		}
	}
	
	private int rowIndex = -1;
	private int columnIndex = -1;
	
	public void setCellIndex(int rowIndex, int columnIndex) { this.rowIndex = rowIndex; this.columnIndex = columnIndex; }
	
	public int getRowIndex() { return rowIndex; }
	
	public int getColumnIndex() { return this.columnIndex; }
	
	private Object value;
	
	public void setValue(Object value) { this.value = value; }
	public Object getValue() { return this.value; }
	
	private Object adjustValue;
	
	public void setAdjustValue(Object adjustValue) { this.adjustValue = adjustValue; } 
	public Object getAdjustValu() { return this.adjustValue; }
	
	private List<Error> error;
	
	public void addError(String code, String message) {
		if (error == null) { 
			error = new ArrayList<Error>();
		}
		error.add(new Error(code, message));
	}
	
	public List<Error> getError() { return this.error; }
	
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("row,col:")
				.append(rowIndex).append(',')
				.append(columnIndex)
				.append(", value:").append(value);
		if (error != null) {
			builder.append(", error:").append(error);
		}
		return builder.toString();
	}
	
}
